home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / os-includeppc / powerup / ppclib / object.h < prev   
C/C++ Source or Header  |  1998-05-24  |  7KB  |  255 lines

  1. #ifndef POWERUP_PPCLIB_OBJECT_H
  2. #define POWERUP_PPCLIB_OBJECT_H
  3.  
  4. /**************************************************
  5.  *
  6.  *
  7.  *              PPCLoadElfObjectTags()
  8.  *
  9.  *
  10.  **************************************************/
  11.  
  12. #define    PPCELFLOADOBJECTTAG_DUMMY    (TAG_USER + 0x23300)
  13.  
  14. /* pointer to a filename of the elf file */
  15. #define    PPCELFLOADTAG_ELFNAME        (PPCELFLOADOBJECTTAG_DUMMY + 0x0)
  16.  
  17. /* pointer to the elf stream resident in memory.
  18.  * PPCELFLOADTAG_ELFNAME and PPCELFLOADTAG_ELFADDRESS
  19.  * are mutually exclusive
  20.  */
  21. #define    PPCELFLOADTAG_ELFADDRESS    (PPCELFLOADOBJECTTAG_DUMMY + 0x1)
  22.  
  23. /* length of the elf stream. This tag is optional
  24.  */
  25. #define    PPCELFLOADTAG_ELFLENGTH        (PPCELFLOADOBJECTTAG_DUMMY + 0x2)
  26.  
  27. /* Stream IO Hook
  28.  * so you can implement your own loader system
  29.  * BOOL CallHookPkt(hook,Handle,&Msg);
  30.  *
  31.  */
  32. #define    PPCELFLOADTAG_HOOK        (PPCELFLOADOBJECTTAG_DUMMY + 0x3)
  33.  
  34. /* Load an ElfObject as a SharedLib Module
  35.  * BOOL
  36.  */
  37. #define    PPCELFLOADTAG_LIBRARY        (PPCELFLOADOBJECTTAG_DUMMY + 0x4)
  38.  
  39. /* File Ptr
  40.  * BPTR
  41.  */
  42. #define    PPCELFLOADTAG_FILE        (PPCELFLOADOBJECTTAG_DUMMY + 0x5)
  43.  
  44. /* pointer to THE name of the elf lib */
  45. #define    PPCELFLOADTAG_ELFLIBNAME    (PPCELFLOADOBJECTTAG_DUMMY + 0x6)
  46.  
  47. /* Ask for at least version x of a SharedLib Module
  48.  * ULONG
  49.  */
  50. #define    PPCELFLOADTAG_LIBVERSION    (PPCELFLOADOBJECTTAG_DUMMY + 0x7)
  51.  
  52. /* Ask for at least revision x of a SharedLib Module
  53.  * ULONG
  54.  */
  55. #define    PPCELFLOADTAG_LIBREVISION    (PPCELFLOADOBJECTTAG_DUMMY + 0x8)
  56.  
  57. /* Ask for the specific version of a SharedLib Module
  58.  * BOOL
  59.  */
  60. #define    PPCELFLOADTAG_LIBEXACTVERSION    (PPCELFLOADOBJECTTAG_DUMMY + 0x9)
  61. #define    PPCELFLOADTAG_LIBEXACTREVISION    (PPCELFLOADOBJECTTAG_DUMMY + 0xa)
  62.  
  63.  
  64.  
  65.  
  66. struct ElfStreamMsg
  67. {
  68.     ULONG    Type;
  69.     ULONG    Arg1;    /* Open->No Meaning,Close->No Meaning,Read->Address,Seek->Offset */
  70.     ULONG    Arg2;    /* Open->No Meaning,Close->No Meaning,Read->Length,Seek->Type */
  71. };
  72.  
  73. /* The Result must be a Handle */
  74. #define    PPCELFLOADTYPE_OPEN    0
  75. /* The Result must be a boolean */
  76. #define    PPCELFLOADTYPE_CLOSE    1
  77. /* The Result must be the read length or -1 */
  78. #define    PPCELFLOADTYPE_READ    2
  79. /* The Result must be the old offset or -1 */
  80. #define    PPCELFLOADTYPE_SEEK    3
  81.  
  82. /**************************************************
  83.  *
  84.  *
  85.  *              PPCGetElfInfos() Tags
  86.  *
  87.  *
  88.  **************************************************/
  89.  
  90. #define    PPCELFINFOTAG_DUMMY        (TAG_USER + 0x23000)
  91.  
  92. /* Returns the name of an elfobject */
  93. #define    PPCELFINFOTAG_NAME        (PPCELFINFOTAG_DUMMY + 0x0)
  94.  
  95. /* Returns infos about a reloc instead of a symbol
  96.  * A special PPCSymbolStruct is passed by ti_Data
  97.  * which tells if you search for a symbol name
  98.  * or wanna find a symbol for a certain address.
  99.  * Result=TRUE if the search was successful and then
  100.  * the SymbolStruct contains other important infos
  101.  */
  102. #define    PPCELFINFOTAG_RELOC        (PPCELFINFOTAG_DUMMY + 0x1)
  103.  
  104.  
  105.  
  106. /* Set this Boolean if you want the infos global.
  107.    Then all Elfobjects are searched.
  108.  */
  109. #define    PPCELFINFOTAG_GLOBAL        (PPCELFINFOTAG_DUMMY + 0x2)
  110.  
  111.  
  112. /* Define this Hook if you wanna get informations about every
  113.    Symbol in a specific ElfObject or in all.
  114.    (ElfObject==NULL || PPCELFINFOTAG_GLOBAL=TRUE)
  115.    That`s the way how the PPCGetObjectInfo() calls your hook.
  116.    MyInfo contains the passed infos, so you could show all
  117.    important symbols or relocs if possible.
  118.  
  119.    CallHookPkt(ScanSymbolHook,
  120.                (APTR) ElfSubStructure, // Not really useful
  121.                (APTR) MyInfo);
  122.  
  123.  */
  124. #define    PPCELFINFOTAG_SCANSYMBOLHOOK    (PPCELFINFOTAG_DUMMY + 0x3)
  125.  
  126.  
  127.  
  128. struct    PPCObjectInfo
  129. {
  130.     ULONG    Address;
  131. /* Name of the Object
  132.  * If this is set PPCGetElfInfo search for the Name
  133.  * Otherwise Address is used to search for an object
  134.  */
  135.     char    *Name;
  136. /* Type of the object
  137.  */
  138.     ULONG    Type;
  139.  
  140. /* Subtype of the object
  141.  * Symbol:
  142.  * COMMON=BSS
  143.  * FUNCTION
  144.  * ...
  145.  * Section:
  146.  *
  147.  * Reloc:
  148.  * Relocation Type
  149.  */
  150.     ULONG    SubType;
  151. /* Symbol:
  152.  * Local,Global,Weak
  153.  * Section:
  154.  *
  155.  */
  156.     ULONG    Binding;
  157. /* Size of the object
  158.  */
  159.     ULONG    Size;
  160. };
  161.  
  162. #define    PPCELFINFOTYPE_SECTION        0
  163.  
  164. /* A Symbol whose SubType defines the real
  165.    symbol Type and Binding contains the
  166.    state of the symbol.
  167.  */
  168. #define    PPCELFINFOTYPE_SYMBOL        1
  169.  
  170. /* A common section(BSS) symbol whose SubType
  171.    defines the real symbol Type and Binding
  172.    contains the state of the symbol.
  173.  */
  174. #define    PPCELFINFOTYPE_COMSYMBOL    2
  175.  
  176. /* A reloc entry is quite simular to a symbol.
  177.    It`s only useful to connect certain instruction
  178.    addresses with certain symbols where you can`t
  179.    calculate the symbol value in an easy way.
  180.    i.e 16 bit PPC addressmodes..ADDR16_HI,HA
  181.  */
  182. #define    PPCELFINFOTYPE_RELOC        3
  183.  
  184.  
  185.  
  186. /*------------------------------------------------------------------------*/
  187. /*  definition of the symbol types`                                            */
  188. /*------------------------------------------------------------------------*/
  189.  
  190. #define    STT_NOTYPE    0
  191. #define    STT_OBJECT    1
  192. #define    STT_FUNC    2
  193. #define    STT_SECTION    3
  194. #define    STT_FILE    4
  195. #define    STT_LOPROC    13
  196. #define    STT_HIPROC    15
  197.  
  198.  
  199. /*------------------------------------------------------------------------*/
  200. /*  definition of the symbol bindings                                        */
  201. /*------------------------------------------------------------------------*/
  202.  
  203. #define    STB_LOCAL        0
  204. #define    STB_GLOBAL        1
  205. #define    STB_WEAK        2
  206. #define    STB_LOPROC        13
  207. #define    STB_HIPROC        15
  208.  
  209.  
  210. /*------------------------------------------------------------------------*/
  211. /*  definition of the supported elf.rela types                            */
  212. /*------------------------------------------------------------------------*/
  213.  
  214. #define  R_PPC_NONE            0
  215. #define  R_PPC_ADDR32            1
  216. #define  R_PPC_ADDR24            2
  217. #define  R_PPC_ADDR16            3
  218. #define  R_PPC_ADDR16_L            4
  219. #define  R_PPC_ADDR16_HI        5
  220. #define  R_PPC_ADDR16_HA        6
  221. #define  R_PPC_ADDR14            7
  222. #define  R_PPC_ADDR14_BRTAKEN        8
  223. #define  R_PPC_ADDR14_BRNTAKEN        9
  224. #define  R_PPC_REL24            10
  225. #define  R_PPC_REL14            11
  226. #define  R_PPC_REL14_BRTAKEN        12
  227. #define  R_PPC_REL14_BRNTAKEN        13
  228. #define  R_PPC_GOT16            14
  229. #define  R_PPC_GOT16_LO            15
  230. #define  R_PPC_GOT16_HI            16
  231. #define  R_PPC_GOT16_HA            17
  232. #define  R_PPC_PLTREL24            18
  233. #define  R_PPC_COPY            19
  234. #define  R_PPC_GLOB_DAT            20
  235. #define  R_PPC_JMP_SLOT            21
  236. #define  R_PPC_RELATIVE            22
  237. #define  R_PPC_LOCAL24PC        23
  238. #define  R_PPC_UADDR32            24
  239. #define  R_PPC_UADDR16            25
  240. #define  R_PPC_REL32            26
  241. #define  R_PPC_PLT32            27
  242. #define  R_PPC_PLTREL32            28
  243. #define  R_PPC_PLT16_LO            29
  244. #define  R_PPC_PLT16_HI            30
  245. #define  R_PPC_PLT16_HA            31
  246. #define  R_PPC_SDAREL16            32
  247. #define  R_PPC_SECTOFF            33
  248. #define  R_PPC_SECTOFF_LO        34
  249. #define  R_PPC_SECTOFF_HI        35
  250. #define  R_PPC_SECTOFF_HA        34
  251.  
  252.  
  253.  
  254. #endif
  255.